<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
		<title></title>
		<script type="text/javascript" src="../script/config.js"></script>
		<style>
			* {
				margin: 0;
				padding: 0;
			}
			body{
      	background-color:white;
      }
			.box {
				height: 100%;
				width: 100%;
				background-color: white;
			}

			.top {
				height: 50px;
				width: 100%;
				margin-top: 80px;
				text-align: center;
				font: 20px "微软雅黑";
				color: rgb(17,64,108);
			}

			.center {
				height: 230px;
				width: 100%;
				text-align: center;
			}

			.center2 {
				height: 32px;
				margin-top: 40px;
				/*line-height: 50px;*/
				text-align: center;
				width: 70%;
				color: #f16c3c;
				margin-left:15%;
				border-bottom:1px solid #f16c3c;
			}
			.mobile_a{
				height:30px;
				vertical-align:top;
				float:left;
				margin-left: 20px;
			}
			.password_a{
				height:30px;
				vertical-align:top;
				float:left;
				margin-left: 20px;
			}
			 ::-webkit-input-placeholder {
				/* WebKit browsers */
				color: rgb(138, 171, 202);
				font-size:18px;
			}
			.center2 input{
				height:32px;
				width:65%;
				border:none;
				list-style: none;
				outline-style: none;
				border: none;
				background: none;
				display: inline-block;
				float: left;
				/*margin-left: 10px;*/
				font-size:18px;
			}
			#password_o,#password_n,#password_s{
				margin-left:10px;
			}
			#mobile{
				margin-left:20px;
			}
			#password_s{
				margin-left:10px;
			}
			.foot{
				width:64%;
				margin-left:18%;
				height:44px;
				background-color:#f16c3c;
				line-height:44px;
				text-align: center;
				color:white;
				font-size:20px;
				border-radius: 10px;
			}
			#kong{
				width:30px;
				height:30px;
				vertical-align:top;
				float:left;
			}
			#foot{
				position:relative;;
				margin:10%;
				width:90%;
				height:50px;
				bottom:0;
				left:0;
				font-size:18px;
			}
			.foot_sure{
				padding-left:17%;
				padding-right:17%;
				padding-top:10px;
				padding-bottom:10px;
				background-color:#f16c3c;
				color:white;
				border-radius:10px;
			}
			.foot_cancle{
				padding-left:17%;
				padding-right:17%;
				padding-top:10px;
				padding-bottom:10px;
				background-color:#f16c3c;
				color:white;
				border-radius:10px;
			}
			input {
				-webkit-tap-highlight-color:transparent;
			}
		</style>
	</head>
	<body>
		<div class="box">
			<div class="top">修改您的密码</div>
			<div class="center">
        <div class="center2">
					<img src="../image/password.png" class="password_a"/><input type="password" id="password_o" class="center2_1" placeholder="旧密码(6~20位)"/>
				</div>
				<div class="center2">
					<img src="../image/password.png" class="password_a"/><input type="password" id="password_n" class="center2_1" placeholder="新密码(6~20位)"/>
				</div>
				<div class="center2">
					<img src="../image/password.png" class="password_a"/><input type="password" class="center2_1" placeholder="确认新密码(6~20位)" id="password_s" style="margin-left=28px;"/>
				</div>
			</div>
			<!-- <div class="foot">确认</div> -->
			<div id="foot">
					<span class="foot_sure" id="foot_sure">确认</span>
					<span class="foot_cancle" id="foot_cancle">取消</span>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../script/jquery-3.2.1.min.js"></script>
	<script type="text/javascript" src="../script/local.js"></script>
	<script type="text/javascript" src="../script/APICloud-rest.js"></script>
	<script type="text/javascript" src="../script/api.js"></script>
	<script>
	apiready = function(){
    var user = $api.getStorage('user');
    var lorry_id=user.lorryid;
    $api.val($api.dom('#password_o'),'');
    $api.val($api.dom('#password_n'),'');
    $api.val($api.dom('#password_s'),'');
	$api.addEvt($api.dom('#foot_sure'), 'click', function(){
        var password_o=$api.val($api.dom("#password_o"));
        var password_n=$api.val($api.dom("#password_n"));
        var password_s=$api.val($api.dom("#password_s"));
             if(password_o.length==0){
               api.toast({
                  msg: '旧密码为空',
                  duration: 1000,
                 location: 'middle'
               });
             }else if(password_n.length==0){
               api.toast({
                  msg: '新密码为空',
                  duration: 1000,
                 location: 'middle'
               });
             }else if(password_s.length==0){
               api.toast({
                  msg: '确认新密码为空',
                  duration: 1000,
                 location: 'middle'
               });
             }else if(password_o.length<6||password_o.length>20){
												api.toast({
													 msg: '旧密码为6~20位',
													 duration: 1000,
													location: 'middle'
												});
							}else if(password_n.length<6||password_n.length>20){
 												api.toast({
 													 msg: '新密码为6~20位',
 													 duration: 1000,
 													location: 'middle'
 												});
 							}else if(password_n.length<6||password_n.length>20){
 												api.toast({
 													 msg: '确认新密码为6~20位',
 													 duration: 1000,
 													location: 'middle'
 												});
 							}else if(password_s!=password_n){
												api.toast({
													 msg: '两次密码输入不一致',
													 duration: 1000,
													location: 'middle'
												});
							}else{
											$api.post(url+'app.php/t_change_password',{
														body:{lorry_id:lorry_id,
                                  password_o:password_o,
                                  password_n:password_n,
                               }
													 },function(ret){
														if(ret.result==0){
															alert("成功");
															// api.openFrame({
															//   url: './firstregister2.html?lorryid='+ret.lorryid,
															//  });
															$api.rmStorage('password');
															var key = 'user';
															var user = {};
															var aa=$api.getStorage(key);
															user.lorryid=aa.lorryid;
															 user.telephone=aa.telephone;
															user.flag= aa.flag
															user.pass= '';
															$api.setStorage(key, user);
															setTimeout("api.closeWin({name:'first_half'})",750);
															setTimeout("api.closeWin({name:'main'})",650);
															 api.openWin({
																 name: 'index',
																 url:  '../index.html',
															 });
														 }else{
															 alert(ret.desc);
															 $api.val($api.dom('#password_o'),'');
															 $api.val($api.dom('#password_n'),'');
															 $api.val($api.dom('#password_s'),'');
														 }
													 });
												 }
											 });
											 $api.addEvt($api.dom('#foot_cancle'), 'click',function(){
												 api.closeWin();
											 });

            }
	</script>
</html>
